package com.xiaoxi.open.design.behavioral.chainofresponsibilitypattern.service.password;

import com.xiaoxi.open.design.behavioral.chainofresponsibilitypattern.domain.password.CheckResult;
import org.springframework.stereotype.Component;

/**
 * @ClassName ContainDigitCheck
 * @Description
 * @Author xiaoxi
 * @Date 2022/7/11 21:33
 * @Version 1.0
 */
@Component
public class ContainDigitCheck extends AbstractCheckPassword {

    @Override
    public void doHandler(String password, CheckResult checkResult) throws Exception {
        char[] chPass = password.toCharArray();

        int numCount = 0;

        for (char pass : chPass) {
            if (Character.isDigit(pass)) {
                ++numCount;
            }
        }

        if (numCount == 0) {
            checkResult.getConfirmInfo().add("数字");
        }

    }
}
